import numpy as np

 # 创建向量
arr1 = np.arange(0,90,10)
print(arr1) # [ 0 10 20 30 40 50 60 70 80]
# 花式索引
print( arr1[ [0,2] ] ) # [ 0 20]

# 创建矩阵
arr2 = np.arange(1,17).reshape(4,4)
print(arr2)
"""
[[ 1  2  3  4]
 [ 5  6  7  8]
 [ 9 10 11 12]
 [13 14 15 16]]
"""
# 花式索引
print( arr2[ [0,1] , [0,1] ] ) # [1 6]
print( arr2[ [0,1,2] , [2,1,0] ] ) # [3 6 9]

# 修改数组元素
arr2[ [0,1,2,3] , [3,2,1,0] ] = 100
print(arr2)
"""[[  1   2   3 100]
 [  5   6 100   8]
 [  9 100  11  12]
 [100  14  15  16]]"""

arr2 = np.arange(1,17).reshape(4,4)
print(arr2[:2,:2])